package org.gbis.openbus.db;

import java.sql.*;

import org.gbis.openbus.*;

import com.sbmoon.db.*;
import com.sbmoon.web.Request;

public class DbManagerStation extends DbManager {

	@Override
	public String getSqlFileName() {
		return "sql500_station.sql";
	}

	@Override
	public Item getItem(QueryResult qr) {
		Station station = new Station();
		station.setId( qr.getString("station_id"));
		station.setName(qr.getString("station_nm"));
		station.setNo( qr.getString("mobile_no"));
		return station;
	}

	public Station getStation( String mobileNo ) {

		SearchResult searchResult = SearchResult.getNewSearchResult();

		getDbManager().getSearchResult( true, searchResult, mobileNo );

		ItemList itemList = searchResult.getItemList();
		if( itemList.getSize() > 0 ) {
			Item item = itemList.get( 0 );
			if( item instanceof Station ) {
				return (Station) item;
			} else {
				return null;
			}
		} else {
			return null;
		}
	}

	private DbManagerStation() {
	}

	public static DbManagerStation getDbManager() {
		return new DbManagerStation();
	}

	public static void main(String[] args) throws Exception {

		Station station =  getDbManager().getStation( "7430" );

	}

}
